/// @author END
/// @date 2022-01-28
/// 视频列表数据模型
import 'dart:convert';

List<VideoData> videoInfoFromJson(List<dynamic> data) =>
    List<VideoData>.from(data.map((x) => VideoData.fromJson(x)));

String videoInfoToJson(List<VideoData> data) =>
    json.encode(List<dynamic>.from(data.map((x) => x.toJson())));

class VideoList {
  final List<VideoData>? data;

  VideoList({
    this.data,
  });

  factory VideoList.fromJson(List<dynamic> parsedJson) {
    List<VideoData> data = <VideoData>[];
    data = parsedJson.map((i) => VideoData.fromJson(i)).toList();
    return new VideoList(data: data);
  }
}

class VideoData {
  // 视频ID
  int id;
  // 作品发布者头像
  String? headPic = '';
  // 作者昵称
  String? nickName = '';
  // 视频名称
  String? title = '';
  // 视频链接
  String pathUrl = '';
  // 视频封面
  String? cover = '';
  // 是否关注
  int? isFollow = 0;
  // 是否点赞
  int? isPraise = 0;
  // 点赞个数
  num? praise = 0;
  // 评论数
  num? comments = 0;
  // 视频来源
  num? source = 0;

  VideoData({
    required this.id,
    this.headPic,
    this.nickName,
    this.title,
    this.isFollow,
    this.isPraise,
    this.praise,
    this.comments,
    this.source,
    required this.pathUrl,
    this.cover,
  });

  factory VideoData.fromJson(Map<String, dynamic> json) {
    return new VideoData(
      id: json['id'],
      headPic: json['headPic'],
      nickName: json['nickName'],
      title: json['title'],
      pathUrl: json['pathUrl'],
      cover: json['cover'],
      isFollow: json['isFollow'],
      isPraise: json['isPraise'],
      praise: json['praise'],
      comments: json['comments'],
      source: json['source'],
    );
  }

  Map<String, dynamic> toJson() => {
        'id': id,
        'headPic': headPic,
        'nickName': nickName,
        'title': title,
        'pathUrl': pathUrl,
        'cover': cover,
        'isFollow': isFollow,
        'isPraise': isPraise,
        'praise': praise,
        'comments': comments,
        'source': source,
      };
}
